package com.woniu.bh.backstage.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.bh.backstage.dto.AdDto;
import com.woniu.bh.backstage.dto.ManagerDto;
import com.woniu.bh.backstage.param.AdRejectParam;
import com.woniu.bh.backstage.param.QueryAdParam;
import com.woniu.bh.backstage.param.QueryManagerParam;
import com.woniu.bh.backstage.service.IAdvertisementService;
import com.woniu.bh.common.core.dto.ResultDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxb
 * @since 2020-10-12
 */
@RestController
@RequestMapping("/ad")
@Slf4j
@Api(value = "广告接口", tags = "广告管理")
public class AdvertisementController {

    @Autowired
    private IAdvertisementService advertisementService;

    @PostMapping("querylist")
    @ApiOperation(value = "查询所有广告列表")
    public ResultDto adquerylist(@RequestBody QueryAdParam queryAdParam){
        log.info("传入数据{}", queryAdParam.toString());
        IPage<AdDto> iPage = advertisementService.selectPage(queryAdParam);
        return ResultDto.success(iPage);
    }

    @PostMapping("auditpass")
    @ApiOperation(value = "广告审核通过")
    public ResultDto adpass(Integer adId){
        log.info("传入数据{}", adId);
        advertisementService.auditPass(adId);
        return ResultDto.success();
    }

    @PostMapping("auditrejected")
    @ApiOperation(value = "广告审核拒绝")
    public ResultDto adauditrejected(@RequestBody AdRejectParam adRejectParam){
        log.info("传入数据{}", adRejectParam.toString());
        advertisementService.auditReject(adRejectParam);
        return ResultDto.success();
    }

    @GetMapping("queryonshelflist")
    @ApiOperation(value = "查询正在上架广告列表")
    public ResultDto adOnshelfList(@RequestBody QueryAdParam queryAdParam){
        log.info("传入数据{}", queryAdParam.toString());
        IPage<AdDto> iPage = advertisementService.selectOnshelfPage(queryAdParam);
        return ResultDto.success(iPage);
    }

    @GetMapping("querywaitonshelflist")
    @ApiOperation(value = "查询审核通过等待上架广告列表")
    public ResultDto adWaitOnshelfList(@RequestBody QueryAdParam queryAdParam){
        log.info("传入数据{}", queryAdParam.toString());
        IPage<AdDto> iPage = advertisementService.selectWaitOnshelfPage(queryAdParam);
        return ResultDto.success(iPage);
    }

}

